﻿using System;
using System.Collections.Generic;

namespace UniRx.Operators
{
	// Token: 0x02000361 RID: 865
	internal class ZipObserver<T> : IObserver<T>
	{
		// Token: 0x060011BA RID: 4538 RVA: 0x0005157C File Offset: 0x0004F97C
		public ZipObserver(object gate, IZipObservable parent, int index, Queue<T> queue)
		{
			this.gate = gate;
			this.parent = parent;
			this.index = index;
			this.queue = queue;
		}

		// Token: 0x060011BB RID: 4539 RVA: 0x000515A4 File Offset: 0x0004F9A4
		public void OnNext(T value)
		{
			object obj = this.gate;
			lock (obj)
			{
				this.queue.Enqueue(value);
				this.parent.Dequeue(this.index);
			}
		}

		// Token: 0x060011BC RID: 4540 RVA: 0x000515F8 File Offset: 0x0004F9F8
		public void OnError(Exception error)
		{
			object obj = this.gate;
			lock (obj)
			{
				this.parent.Fail(error);
			}
		}

		// Token: 0x060011BD RID: 4541 RVA: 0x0005163C File Offset: 0x0004FA3C
		public void OnCompleted()
		{
			object obj = this.gate;
			lock (obj)
			{
				this.parent.Done(this.index);
			}
		}

		// Token: 0x04000A93 RID: 2707
		private readonly object gate;

		// Token: 0x04000A94 RID: 2708
		private readonly IZipObservable parent;

		// Token: 0x04000A95 RID: 2709
		private readonly int index;

		// Token: 0x04000A96 RID: 2710
		private readonly Queue<T> queue;
	}
}
